<html>
<head>
<script type="text/javascript" src="/statics/js/jquery-3.2.1.min.js" ></script>
</head>
<body>
	<div style="width: 100%;text-align: center;height: 200px;">
		<button style="margin-top: 200px;height: 50px;font-size: 40px;color:blue" data-event="dopay">发起支付</button>
	</div>
</body>
</html>

<!-- 微信内置方法，不需引入任何微信相关的js文件 -->
<script type="text/javascript">
//调用微信JS api 支付
function jsApiCall() {
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		<?php echo json_encode($jsApiParameters); ?>,
		function(res){
			if(res.err_msg == "get_brand_wcpay_request:ok") {
				// 这里写支付成功的回调
			} else if (res.err_msg == "get_brand_wcpay_request:fail") {
				weui.topTips('支付失败，请稍后再试！', 3000);
				window.location.reload();
			} else if (res.err_msg == "get_brand_wcpay_request:cancel"){
				weui.topTips('账号未激活或到期后无法使用会给您带来未知的损失！', 5000);
			} else {
				window.location.reload();
			}
		}
	);
}

$('[data-event="dopay"]').bind('click',function() {
	if (typeof WeixinJSBridge == "undefined"){
	    if( document.addEventListener ){
	        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
	    }else if (document.attachEvent){
	        document.attachEvent('WeixinJSBridgeReady', jsApiCall);
	        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
	    }
	}else{
	    jsApiCall();
	}
})
</script>